package objects;

import java.util.ArrayList;
import java.util.List;

import objects.alignments.CollapsedAlignment;
import objects.alignments.IntronAlignment;
import objects.alignments.IntronCollapsedAlignment;
import objects.alignments.SpliceAlignment;
import objects.alignments.SpliceCollapsedAlignment;
import objects.alignments.Subset0Alignment;


/**
 * Used in the Subset0Viewport to keep track of valid positions of the graph.
 * 
 * @author stephenbwilliamson
 * 
 */
public class Line {

	private static int maxID = 0;
	private int id = 0;
	private List<Subset0Alignment> taken = null;

	public Line() {
		this.id = ++maxID;
		this.taken = new ArrayList<Subset0Alignment>();
	}

	public Line(int id) {
		if (id > maxID)
			maxID = id;

		this.id = id;
		this.taken = new ArrayList<Subset0Alignment>();
	}

	public static void resetMaxID() {
		maxID = 0;
	}

	public static int getMaxID() {
		return maxID;
	}

	public int getID() {
		return id;
	}

	public boolean isLoadable(Subset0Alignment a) {
		if (a == null)
			return false;

		for (Subset0Alignment alignment : taken) {
			ValidPosition position = alignment.getMaxBound();
			if (position.intersects(a.getMaxBound()))
				return false;
		}
		return true;
	}

	public List<Subset0Alignment> getAlignments() {
		return taken;
	}

	public void addPosition(Subset0Alignment vp) {
		taken.add(vp);
	}

}
